/***
 * * PROJECT
 * *    ATaG
 * * VERSION
 * *    $Revision: 1.5 $
 * * DATE
 * *    $Date: 2006/12/14 23:49:06 $
 * * LOG
 * *    $Log: NodeLocation.java,v $
 * *    Revision 1.5  2006/12/14 23:49:06  lmottola
 * *    Added serialVersionUID.
 * *
 * *    Revision 1.4  2006/12/14 23:48:29  lmottola
 * *    Bug fix for Math class.
 * *
 * *    Revision 1.3  2006/12/13 11:59:54  animesh
 * *    added method for computing distance.
 * *
 * *    Revision 1.2  2006/10/19 21:21:52  lmottola
 * *    Added CVS preamble.
 * *
 * *
 * *   ATaG (Abstract Task Graph) - Data-driven Macroprogramming for
 * *                                Sensor Networks
 * *
 * *   This program is free software; you can redistribute it and/or
 * *   modify it under the terms of the GNU General Public License
 * *   as published by the Free Software Foundation; either version 2
 * *   of the License, or (at your option) any later version.
 * *
 * *   This program is distributed in the hope that it will be useful,
 * *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * *   GNU General Public License for more details.
 * *
 * *   You should have received a copy of the GNU General Public License
 * *   along with this program; if not, you may find a copy at the FSF web
 * *   site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
 * *   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * *   Boston, MA  02111-1307, USA
 ***/

package atag.runtime;

import java.io.Serializable;

/**
 * The class for the node location. Maybe later, the coordinates themselves
 * should be cast [from float or int or whatever]
 * 
 * @author Animesh
 */
public class NodeLocation implements Cloneable, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * X coordinate
	 */
	float x;

	/**
	 * Y coordinate
	 */
	float y;

	/**
	 * Creates a new instance of NodeLocation
	 */
	public NodeLocation() {
	}

	/**
	 * Creates a new instance of NodeLocation
	 */
	public NodeLocation(float argX, float argY) {
		x = argX;
		y = argY;
	}

	/**
	 * Set the value of X
	 */
	public void setX(float argX) {
		x = argX;
	}

	/**
	 * Set the value of Y
	 */
	public void setY(float argY) {
		y = argY;
	}

	/**
	 * Gets the value of X
	 */
	public float getX() {
		return x;
	}

	/**
	 * Gets the value of Y
	 */
	public float getY() {
		return y;
	}

	public NodeLocation clone() {
		Object returnobject = null;
		try {
			returnobject = super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return (NodeLocation) returnobject;
	}

	public boolean equals(NodeLocation arg_location) {
		return ((this.getX() == arg_location.getX()) && (this.getY() == arg_location
				.getY()));
	}

	public double distanceFrom(NodeLocation n) {
		return Math.sqrt((this.x - n.getX()) * (this.x - n.getX())
				+ (this.y - n.getY()) * (this.y - n.getY()));
	}
}
